package com.springcloud.zuul.common.utlis;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @program: springcloud-zuul
 * @description:
 * @author: zhlu
 * @create: 2019-12-18 17:25
 * @Introduction(说明背景故事)
 **/
public class ExceptionLogUtil {
    private ExceptionLogUtil(){
    }

    /**
     * 完整的堆栈信息
     *
     * @param e Exception
     * @return Full StackTrace
     */
    public static String getStackTrace(Exception e) {

        try (StringWriter sw =new StringWriter(); PrintWriter pw =new PrintWriter(sw)){
            e.printStackTrace(pw);
            return String.valueOf(sw);
        }catch (IOException e1){
            e1.printStackTrace();
        }
        return "";
    }
}
